Add plugin command support for nix repl
#3934
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation: I want to make https://github.com/lf-/nix-doc a repl command, but it is useful to be able to extend the REPL otherwise.
Side note: In case my documentation changes look weird, there was an error in the documentation, which previously claimed that
RegisterCommand
was possible from a plugin, which it is not, because it is insrc/nix
and thus cannot be linked to by a library since that directory only links into an executable. I encountered this myself when initially implementing this feature and that is why I had to refactor the REPL logic out into libexpr.functions from editline so we don't introduce extra dependencies for
libexpr
trick with closures on the nix side (that are effectively globals
[static vars in a templated function per-closure], but
unique per repl user and thus not as ugly ;p)
support for it according to
rg READLINE
and it is thus dead code